#pragma once
#ifdef LIT_OGRE_SUPPORT

#ifndef __LIT__DISPLAY__LIGHT__HH__
#define __LIT__DISPLAY__LIGHT__HH__

#include <OgreLight.h>
#include <LitPointer.hpp>
#include <LitLightTypes.h>
#include <LitPrerequisites.h>
#include <LitMovable.h>
#include <LitVector.hpp>

namespace Lit
{
	class LIT_API Light : public Movable
	{
	public:
		typedef LightType Type;
	protected:
		OgreLightPtr				mLight;
		Ogre::NameGenerator*		mNameGen;
		Type						mBaseType;
		Ogre::Vector3				mBasePosition;
		Ogre::Vector3				mBaseDirection;
	public:
		Light(const String &name="", Type type=LT_POINT, const Ogre::Vector3& position=Ogre::Vector3::ZERO, const Ogre::Vector3& direction=Ogre::Vector3::NEGATIVE_UNIT_Y);
		Light(const Light& rk);
		~Light(void);
		
		void exportAttribs( TiXmlElement * elem );
		void importAttribs( TiXmlElement * elem );

		const OgreLightPtr::Ptr operator*() const;
		const OgreLightPtr::Ptr operator->() const;
		OgreLightPtr::Ptr operator*();
		OgreLightPtr::Ptr operator->();
		
		bool isCastingShadows() const;
		void setCastShadows( bool state );
		
		Ogre::Real attenuationRange() const;
		Ogre::Real attenuationConstant() const;
		Ogre::Real attenuationLinear() const;
		Ogre::Real attenuationQuadratic() const;

		void setAttenuationRange(Ogre::Real a);
		void setAttenuationConstant(Ogre::Real a);
		void setAttenuationLinear(Ogre::Real a);
		void setAttenuationQuadratic(Ogre::Real a);

		
		Ogre::Vector3 getPosition() const;
		Ogre::Vector3 direction() const;
		Ogre::ColourValue diffuseColour() const;
		Ogre::ColourValue specularColour() const;

		void setPosition( const Ogre::Vector3&p );
		void setDirection( const Ogre::Vector3&d );
		void setDiffuseColour( const Ogre::ColourValue&c );
		void setSpecularColour( const Ogre::ColourValue&c );
		

		Ogre::Degree spotlightInnerAngle() const;
		Ogre::Degree spotlightOuterAngle() const;
		Ogre::Real spotlightFalloff() const;

		void setSpotlightRange( const Ogre::Degree& in, const Ogre::Degree& out, Ogre::Real falloff = 1  );
		void setSpotlightInnerAngle( const Ogre::Degree& in  );
		void setSpotlightOuterAngle( const Ogre::Degree& out  );
		void setSpotlightFalloff( Ogre::Real falloff = 1 );

		String typestr() const;
		Type type() const{ return Type(mLight->getType()); }
		void setType( Type t ){ mLight->setType( Ogre::Light::LightTypes(t) ); }

		OgreLightPtr light(){ return mLight; }

		void replaceLight( Type type=LT_POINT, const Ogre::Vector3& position=Ogre::Vector3::ZERO, const Ogre::Vector3& direction=Ogre::Vector3::ZERO );

		void create(OgreSceneManagerPtr mgr);
		void destroy();
	};

	typedef RefPtr<Light>							LightPtr;
	typedef Vector<LightPtr>						LightPtrList;
};

#endif

#endif // IF DEFINED LIT_OGRE_SUPPORT